# Nano clone
MACH=arduino:avr:nano:cpu=atmega328
PORT=/dev/ttyUSB1
CPU=atmega328p
BAUD=57600

HARD=/usr/share/arduino/hardware
TOOLS=/usr/share/arduino/tools

SRC=cwstation.c
BASE=$(shell pwd)
BUILD=$(BASE)/.build
OBJ=.build/$(SRC).hex

all:
	rm -rf .build; mkdir .build 
	arduino-builder -hardware $(HARD) \
	-tools $(TOOLS) -fqbn $(MACH) \
	-prefs=build.extra_flags=-Wall \
	-build-path $(BUILD) -compile $(SRC)

upload:
	avrdude -V -F -C /etc/avrdude.conf -c arduino \
	-p $(CPU) -P $(PORT) -b $(BAUD) \
	-U flash:w:$(OBJ)

upload2:
	scp $(OBJ) cjb@ermine:/tmp/a.obj
	ssh cjb@ermine "avrdude -V -F -C /etc/avrdude.conf -c arduino \
	-p atmega328p -P /dev/ttyUSB0 -b 57600 \
	-U flash:w:/tmp/a.obj"

clean:
	rm -rf $(BUILD)
	mkdir $(BUILD)
